/*
 * @Descripttion: 
 * @version: 
 * @Author: hutao
 * @Date: 2023-08-22 19:44:23
 * @LastEditors: hutao
 * @LastEditTime: 2023-08-22 19:50:13
 */
import axios from 'axios'
import { _axios } from 'vue-kst-auth';
export default class UploadAdapter {
  constructor(loader: any) {
    (this as any).loader = loader
  }
  upload() {
    return (this as any).loader.file.then((file: string | Blob) => new Promise((resolve, reject) => {
      const data = new FormData()
      data.append('file', file)
      _axios({
        url: '/files/api/filing/file/upload',
        method: 'post',
        data: data,
        headers: { 'Content-Type': 'multipart/form-data' },
      }).then((res) => {
        if (res.status === 200) {
          const url = res.data.url // 后台返回的上传成功后的图片地址
          resolve({
            default: url
          })
        }
      })
        .catch(error => {
          reject(error)
        })
    }))
  }
  abort() {
    //
  }
}


